package com.apartment.common.config;

import com.apartment.common.utils.StringUtils;
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;

public class P6SpyLogger implements MessageFormattingStrategy {
    public P6SpyLogger() {
    }
    @Override
    public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
        return StringUtils.isNotBlank(sql) ? " 消耗时间：" + elapsed + " ms " + now + "\n 执行SQL：\n" + sql.replaceAll("[\\s]+", " ") + "\n" : "";
    }
}
